import Https2 from "@/utils/Https2";
import { PageContainer } from "@ant-design/pro-components";
import { FC, useEffect, useState } from "react";
import { useLocation } from "umi";
import BrandBasic from "./basic";
import Order from "./order";
import BrandVenue from "./venue";
const BrandInformation: FC<any> = () => {
  const [activeKey, setActiveKey] = useState("0");
  const [regionList, setRegionList] = useState([]);
  const stateParams = useLocation().state;
  const getRegion = async () => {
    let res = await Https2.get("/venue/info/venueRegionList", {}, true);
    if (res.code == 200) {
      setRegionList(res.data);
    } else {
      setRegionList([]);
    }
  };
  useEffect(() => {
    getRegion();
  }, []);
  useEffect(() => {
    if (stateParams) {
      setActiveKey(stateParams.type);
    }
  }, [stateParams]);
  return (
    <PageContainer
      title="品牌信息"
      tabList={[
        {
          tab: "品牌信息",
          key: "0",
        },
        {
          tab: "场馆列表",
          key: "1",
        },
        {
          tab: "订单管理",
          key: "2",
        },
      ]}
      onTabChange={(e) => {
        setActiveKey(e);
      }}
      tabActiveKey={activeKey}
    >
      {activeKey == "0" && (
        <BrandBasic
          onSuccess={(e) => {
            setActiveKey(e);
          }}
        ></BrandBasic>
      )}
      {activeKey == "1" && (
        <BrandVenue
          onSuccess={(e) => {
            setActiveKey(e);
          }}
          regionList={regionList}
        ></BrandVenue>
      )}
      {activeKey == "2" && <Order></Order>}
    </PageContainer>
  );
};
export default BrandInformation;
